<template>
	<view class="multipleselection" @click="slect_item(it)">
			<text>{{it.name}}</text>
	</view>
</template>

<script>
	export default {
		name: 'yyMultipleselection',
		props: {
			value: {
				type: [String, Array, Number],
				default: () => {
					return ''
				}
			},
			config: {
				type: Object,
				default: () => {}
			},
			config_item:{
				type: Object,
				default: () => {}
			}
		},
		data() {
			return {
				// modelValue: this.value,
				item: this.config,
				it:this.config_item,
			}
		},
		computed:{
			modelValue: {
				get() {
					return this.value
				},
				set(value) {
					console.log('modelValue', value)
					this.$emit('input', value)
				}
			},
		},
		watch:{
			
		},
		onLoad() {

		},
		methods: {
			slect_item(item) {
			if(this.modelValue==''){
				this.modelValue=item.name
			}else{
				let brr=this.modelValue.split(',')
				
					let index=brr.indexOf(item.name)
					if(index>-1){
						brr.splice(index,1)
					}else{
						brr.push(item.name)
					}
					this.modelValue=brr.join()
			}
			}
		}
	}
</script>

<style lang="scss">
	.multipleselection {
		width: 670rpx;
		height: 100rpx;
		text-align: center;
		line-height: 100rpx;

		border-radius: 50rpx;
		margin-bottom: 20rpx;

		text {
			color: #FF7612;
			font-size: 34rpx;
		}

	}

	.select {
		border: 2rpx solid #FF7612;
		background-color: #FFEEE2;
	}

	.not_select {
		border: 2rpx solid #E1E1E1;
		background-color: #fff;
	}
</style>
